package com.heima.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dto.SensitiveDto;
import com.heima.model.admin.pojo.AdSensitive;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(tags = "敏感词管理")
public class AdSensitiveController {

    @Autowired
    private AdSensitiveService adSensitiveService;

    @PostMapping("/list")
    @ApiOperation("查询敏感词列表")
    public ResponseResult list(@RequestBody SensitiveDto dto) {
        IPage page = adSensitiveService.list(dto);
        return PageResponseResult.success(page);
    }

    @PostMapping("/save")
    @ApiOperation("新增敏感词")
    public ResponseResult insert(@RequestBody AdSensitive wmSensitive) {
        adSensitiveService.insert(wmSensitive);
        return ResponseResult.success();
    }

    @PostMapping("/update")
    @ApiOperation("修改敏感词")
    public ResponseResult update(@RequestBody AdSensitive wmSensitive) {
        adSensitiveService.update(wmSensitive);
        return ResponseResult.success();
    }

    @DeleteMapping("/del/{id}")
    @ApiOperation("删除敏感词")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        adSensitiveService.delete(id);
        return ResponseResult.success();
    }
}
